package com.agileboot.domain.airport.reform.model;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.agileboot.domain.airport.reform.command.AddReformMainCommand;
import com.agileboot.domain.airport.reform.command.UpdateReformMainCommand;
import com.agileboot.domain.airport.reform.db.SirReformMainEntity;
import com.agileboot.domain.airport.reform.db.SirReformMainService;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public class ReformMainModel extends SirReformMainEntity {

    private SirReformMainService reformService;

    public ReformMainModel(SirReformMainService reformService) {
        this.reformService = reformService;
    }

    public ReformMainModel(SirReformMainEntity entity, SirReformMainService reformService) {
        BeanUtil.copyProperties(entity, this);
        this.reformService = reformService;
    }

    public void loadFromAddCommand(AddReformMainCommand command) {
        BeanUtil.copyProperties(command, this);
    }

    public void loadFromUpdateCommand(UpdateReformMainCommand command) {
        // 只复制 command 中非 null 的属性，保留 this 中已有的属性值
        BeanUtil.copyProperties(command, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
